﻿@model Apps.Models.WMS.WMS_Sale_OrderModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.WMS;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "修改";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<script type="text/javascript">
    $(function () {
     $('#Lot').combogrid({
        panelWidth: 300,
        panelHeight: 150,
        sortName: 'Lot',
        idField: 'LotDisp',
        textField: 'LotDisp',
        url: '@Url.Action("GetLotsByPart", "Inv")',
        method: 'post',
        editable: false,
        onSelect: onSelect,
        columns: [[
            { field: 'Lot', title: '批次号', width: 50, hidden: true },
            {
                field: 'LotDisp', title: '批次号', width: 50
            },
            {field:'Qty',title:'现有量',width:50},
            { field: 'StockQty', title: '备料数', width: 80, sortable: true, align: 'right' },
            { field: 'AvailableQty', title: '可用数量', width: 80, sortable: true, align: 'right' }
        ]],
        fitColumns: true
        });

    $("#btnSave").click(function () {
        if ($("form").valid()) {
            $.ajax({
                url: "@Url.Action("Edit")",
                type: "Post",
                data: $("form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.type == 1) {
                        window.parent.frameReturnByMes(data.message);
                        window.parent.frameReturnByReload(false);
                        window.parent.frameReturnByClose()
                    }
                    else {
                        window.parent.frameReturnByMes(data.message);
                    }
                }
            });
        }
        return false;
    });
    $("#btnReturn").click(function () {
         window.parent.frameReturnByClose();
    });
});
function frameReturnByClose() {
$("#modalwindow").window('close');
}
function frameReturnByMes(mes) {
$.messageBox5s(Lang.Tip, mes);
    }
function onSelect(index, row) {
        $("#Qty").html(row.AvailableQty);
    }
function LoadLot() {
        var invId = $("#InvId").val();
        var subInvId = "";
        var partId = $("#PartId").val();
        $("#Lot").combogrid('grid').datagrid("load", { partId: partId, invId: invId });
    };
</script>
<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.CreateTime)
    @Html.HiddenFor(model => model.CreatePerson)
    @Html.HiddenFor(model => model.PrintMan)
    @Html.HiddenFor(model => model.PrintStaus)
    @Html.HiddenFor(model => model.PrintDate)
    //@Html.HiddenFor(model => model.InvId)
    @Html.HiddenFor(model => model.ConfirmMan)
    @Html.HiddenFor(model => model.ConfirmDate)
    @Html.HiddenFor(model => model.ConfirmStatus)
    <table class="formtable">
        <tbody>
            <tr>
                <th>
                    @Html.LabelFor(model => model.SaleBillNum)：
                </th>
                <td>
                    @Html.EditorFor(model => model.SaleBillNum)
                </td>
                <td>@Html.ValidationMessageFor(model => model.SaleBillNum)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.SellBillNum)：
                </th>
                <td>
                    @*@Html.EditorFor(model => model.SellBillNum)*@
                    @Html.ReadOnlyTextBoxFor(model => model.SellBillNum, true)
                </td>
                <td>@Html.ValidationMessageFor(model => model.SellBillNum)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.PlanDeliveryDate)：
                </th>
                <td>
                    @Html.TextBoxFor(model => model.PlanDeliveryDate, new { @onClick = "WdatePicker()", @style = "width: 105px" })
                </td>
                <td>@Html.ValidationMessageFor(model => model.PlanDeliveryDate)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.CustomerId)：
                </th>
                <td>
                    <div style="height:0;width:0;overflow:hidden">
                        @Html.EditorFor(model => model.CustomerId)
                    </div>
                    <input id="CustomerList" name="PartList" value="@Model.CustomerShortName" readonly="readonly" type="text" style="width: 180px; display: inline; background: #dedede; ">
                    <a class="fa fa-plus-square color-gray fa-lg" href="javascript:showSelCustomer()"></a>
                    <script type="text/javascript">
                        function showSelCustomer() {
                            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/WMS/Customer/CustomerLookUp'></iframe>");
                            $("#modalwindow").window({ title: '选择客户', width: SetGridWidthSub(20), height: SetGridHeightSub(45), iconCls: 'fa fa-plus' }).window('open');
                        }

                        function SetSelResultForCustomer(result, resultName) {
                            $("#CustomerId").val(result);
                            $("#CustomerList").val(resultName);
                        }
                    </script>
                </td>
                <td>@Html.ValidationMessageFor(model => model.CustomerId)</td>
            </tr>
            <tr>
                <th>
                    物料编码:
                </th>
                <td>
                    <div style="height:0;width:0;overflow:hidden">
                        @Html.EditorFor(model => model.PartId)
                    </div>
                    <input id="PartList" name="PartList" value="@Model.PartCode" readonly="readonly" type="text" style="width: 180px; display: inline; background: #dedede; ">
                    <a class="fa fa-plus-square color-gray fa-lg" href="javascript:showSelPart()"></a>
                    <script type="text/javascript">
                        function showSelPart() {
                            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/WMS/Part/PartLookUp'></iframe>");
                            $("#modalwindow").window({ title: '选择物料', width: SetGridWidthSub(20), height: SetGridHeightSub(45), iconCls: 'fa fa-plus' }).window('open');
                        }

                        function SetSelResultForPart(result, resultName) {
                            $("#PartId").val(result);
                            $("#PartList").val(resultName);
                            LoadLot();
                        }
                    </script>
                </td>
                <td>@Html.ValidationMessageFor(model => model.PartId)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Qty)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Qty)
                </td>
                <td>@Html.ValidationMessageFor(model => model.Qty)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.BoxQty)：
                </th>
                <td>
                    @Html.EditorFor(model => model.BoxQty)
                </td>
                <td>@Html.ValidationMessageFor(model => model.BoxQty)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.InvId)：
                </th>
                <td>
                    @Html.DropDownListFor(model => model.InvId, ViewBag.Inv as SelectList, new { @onchange = "LoadLot()" })
                </td>
                <td>@Html.ValidationMessageFor(model => model.InvId)</td>
            </tr>
            @*<tr>
            <th>
                @Html.LabelFor(model => model.SubInvId)：
            </th>
            <td>
                @Html.EditorFor(model => model.SubInvId)
            </td>
            <td>@Html.ValidationMessageFor(model => model.SubInvId)</td>
        </tr>*@
            <tr>
                <th>
                    批次号：
                </th>
                <td>
                    <input id="Lot" name="Lot" value="@Model.Lot">
                    <label id="Qty" for="Lot" name="Qty"></label>
                </td>
                <td>@Html.ValidationMessageFor(model => model.Lot)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Volume)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Volume)
                </td>
                <td>@Html.ValidationMessageFor(model => model.Volume)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Remark)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Remark)
                </td>
                <td>@Html.ValidationMessageFor(model => model.Remark)</td>
            </tr>
            @*<tr>
            <th>
                @Html.LabelFor(model => model.PrintStaus)：
            </th>
            <td>
                @Html.EditorFor(model => model.PrintStaus)
            </td>
            <td>@Html.ValidationMessageFor(model => model.PrintStaus)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.PrintDate)：
            </th>
            <td>
                @Html.TextBoxFor(model => model.PrintDate, new { @onClick = "WdatePicker()", @style = "width: 105px" })
            </td>
            <td>@Html.ValidationMessageFor(model => model.PrintDate)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.PrintMan)：
            </th>
            <td>
                @Html.EditorFor(model => model.PrintMan)
            </td>
            <td>@Html.ValidationMessageFor(model => model.PrintMan)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ConfirmStatus)：
            </th>
            <td>
                @Html.EditorFor(model => model.ConfirmStatus)
            </td>
            <td>@Html.ValidationMessageFor(model => model.ConfirmStatus)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ConfirmMan)：
            </th>
            <td>
                @Html.EditorFor(model => model.ConfirmMan)
            </td>
            <td>@Html.ValidationMessageFor(model => model.ConfirmMan)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ConfirmDate)：
            </th>
            <td>
                @Html.EditorFor(model => model.ConfirmDate)
            </td>
            <td>@Html.ValidationMessageFor(model => model.ConfirmDate)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr1)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr1)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr1)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr2)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr2)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr2)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr3)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr3)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr3)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr4)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr4)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr4)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Attr5)：
            </th>
            <td>
                @Html.EditorFor(model => model.Attr5)
            </td>
            <td>@Html.ValidationMessageFor(model => model.Attr5)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.CreatePerson)：
            </th>
            <td>
                @Html.EditorFor(model => model.CreatePerson)
            </td>
            <td>@Html.ValidationMessageFor(model => model.CreatePerson)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ModifyPerson)：
            </th>
            <td>
                @Html.EditorFor(model => model.ModifyPerson)
            </td>
            <td>@Html.ValidationMessageFor(model => model.ModifyPerson)</td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ModifyTime)：
            </th>
            <td>
                @Html.TextBoxFor(model => model.ModifyTime, new { @onClick = "WdatePicker()", @style = "width: 105px" })
            </td>
            <td>@Html.ValidationMessageFor(model => model.ModifyTime)</td>
        </tr>*@
        </tbody>
    </table>
}

